﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Serialization;

namespace FerrSimplicity
{
    public class ManagerPrefabs
    {
        #region Singleton
        private static ManagerPrefabs mInstance = null;
        public  static ManagerPrefabs Instance
        {
            get { if (mInstance == null) mInstance = new ManagerPrefabs(); return mInstance; }
        }
        private ManagerPrefabs() { mPrefabs = new Dictionary<string, BaseGameObject>(); }
        #endregion

        #region Fields
        private Dictionary<string, BaseGameObject> mPrefabs;
        #endregion

        #region Methods
        public void           Add      (string aPrefabName, BaseGameObject aPrefab)
        {
            mPrefabs.Add(aPrefabName, aPrefab);
        }
        public bool           HasPrefab(string aPrefabName)
        {
            return mPrefabs.ContainsKey(aPrefabName);
        }
        public BaseGameObject Create   (string aPrefabName)
        {
            if (!HasPrefab(aPrefabName))
                throw new ArgumentException("Prefab name does not exist!");

            return (BaseGameObject)mPrefabs[aPrefabName].Clone();
        }
        #endregion
    }
}
